package myp72;

import client.Client;

import comm.ClientPriority;

public class Client72 extends Client {

	private int d;
	private int numTasks;

	public Client72(ClientPriority priority, int problemNumber, int version,
			String masterAddress, int masterPort, String codeServerAddress,
			int codeServerPort) {
		super(priority, problemNumber, version, masterAddress, masterPort,
				codeServerAddress, codeServerPort);

	}

	
	public void execute() {
		long time = System.currentTimeMillis();
		d = 1000000;
		numTasks = 1000;
		long ct2 = 0;


		new Thread(new Runnable(){

			@Override
			public void run() {
				for (int ii = 0; ii < numTasks; ii++) {
					commit(new TaskP72(d,ii + 1, numTasks));
				}
			}

		}).start();
		System.out.println("Starting ...");

		for (int ii = 0; ii < numTasks; ii++) {
			ct2 += ((ResultP72) (getNextResult())).getValue();
			if(ii%100 == 0){
				System.out.println(ii);
			}
		}
		System.out.println("Time: " + (System.currentTimeMillis() - time));

		System.out.println(ct2);


	}

	public static void main(String[] args) {
		new Client72(ClientPriority.HIGH, 4, 4, "localhost", 0, "localhost", 0);
	}


}
